"""
# 读取A文件计算文件中每行每个单词出现次数，随后以单词+出现次数的方式从大到小逐行写入B文件中
#A文件的内容在评论中给出，或者自己写一个
APath=r'C:\Users\admin\Desktop\PyTest2\A.txt'
BPath=r"C:\Users\admin\Desktop\PyTest2\B.txt"
A = open(APath,encoding = "utf-8")
A1=A.read().split('\n')

B = open(BPath,'w',encoding = "utf-8")

for i in A1:
    A2 = i.split(",")
    B1=dict()
    for ii in A2:
        if ii not in B1 :
            B1[ii] = A2.count(ii)#//这里使用了一个函数计算器数量，但用正则表达式应该也行
    sorted(B1.values(),reverse=False)
    for key in B1 :
        B.write(str(key)+":"+str(B1[key])+" ")
    B.write('\n')

B.close()
A.close()
"""